const ExtensionVersion = '1.0.477';
import { translateBaidu } from './public/translateBaidu.js';
import { BilibiliPublicCallBack } from './public/videoGroup/bilibili.js';
import { BiliSearchCallBack } from './public/videoGroup/biliSearch.js';
import { TranslateGoogleCnCallBack } from './public/translateGoole.js';
import {
  addCopyStyle,
  CopySuccessTips,
  copyToClipboard,
} from './public/public.js';
import { YoukuCallBack } from './public/videoGroup/YoukuCallBack.js';
import { CCTVCallBack } from './public/videoGroup/CCTVCallBack.js';
import { IQYCallBack } from './public/videoGroup/IQYCallBack.js';
import { youtubeCallBack } from './public/videoGroup/youtube.js';
import { Dy555CallBack } from './public/videoGroup/dy555CallBack.js';
// import { EneteduCallBack } from './public/videoGroup/EneteduCallBack.js';
import { localhostCallBack } from './public/localhost/localhostCallBack.js';
import { Weixin_BOOK } from './public/Weixin_BOOK.js';
import { NaobiaoCasllBack } from './public/tools/NaobiaoCasllBack.js';
import { Weixin_wenzhang } from './public/Weixin_wenzhang.js';
import { PerplexityAi } from './public/copy/perplexityAi.js';
import { kimiMoonshot } from './public/copy/kimiMoonshot.js';
import { COZE_callback } from './public/ai/coze.js';

window.onload = () => {
  addCopyStyle(); // 添加复制成功的函数
  window.CopySuccessTips = CopySuccessTips;
  window.copyToClipboard = copyToClipboard;
  console.log(
    `【boxue】插件已加载！ 版本：${ExtensionVersion} 进入本页面时间:${getTime()}`
  );
  if (window.location.host.includes('fanyi.baidu.com')) {
    translateBaidu(); // 百度翻译
  } else if (window.location.host.startsWith('search.bilibili.com')) {
    BiliSearchCallBack(); // B站搜索的回调
  } else if (window.location.host.startsWith('www.bilibili.com')) {
    BilibiliPublicCallBack(); // B站的回调
  } else if (window.location.host.startsWith('translate.google.com')) {
    TranslateGoogleCnCallBack(); // 谷歌翻译
  } else if (window.location.hostname === 'weread.qq.com') {
    Weixin_BOOK(); // 微信读书
  } else if (window.location.origin === 'https://v.youku.com') {
    YoukuCallBack(); // 优酷视频的回调
  } else if (['tv.cctv.com', 'v.cctv.com'].includes(window.location.hostname)) {
    CCTVCallBack(); // 央视回调
  } else if (window.location.hostname === 'www.iqiyi.com') {
    IQYCallBack(); // 爱奇艺的回调
  } else if (window.location.hostname === 'www.youtube.com') {
    youtubeCallBack();
  } else if (window.location.hostname === 'onlinenew.enetedu.com') {
    // setTimeout(() => {
    //   EneteduCallBack();
    //   setInterval(() => {
    //     console.log(
    //       '%cindex.js 34 ["执行回调"]',
    //       'color: #43bb88;font-size: 24px;',
    //       `执行回调 ${getTime()}`
    //     );
    //     EneteduCallBack();
    //   }, 10000);
    // }, 500); // 雅文学院播放视频的回调函数
  } else if (window.location.href.startsWith('http://localhost:')) {
    localhostCallBack(); // 开发环境的配置
  } else if (
    [
      '555flim.site',
      '555dy1.com',
      '555uu.online',
      '5movie.shop',
      '5sene.site',
      '5srn5.com',
      '5strm.com',
      'wu5ys.com',
      'flick555land.com',
      's5knz.com',
      'film555space.com',
      'ww3pl7.art',
    ].includes(window.location.hostname)
  ) {
    Dy555CallBack();
  } else if (['https://www.naobiao.com'].includes(location.href)) {
    NaobiaoCasllBack(); // 闹表网的回调
  } else if (['https://mp.weixin.qq.com'].includes(window.location.origin)) {
    Weixin_wenzhang(); // 微信订阅号
  } else if (['https://www.perplexity.ai'].includes(window.location.origin)) {
    PerplexityAi(); // perplexity.ai
  } else if (['https://kimi.moonshot.cn'].includes(window.location.origin)) {
    kimiMoonshot();
  } else if (window.location.href.startsWith('https://www.coze.com/space/')) {
    COZE_callback(); // 扣子
  }
};
function getTime(time = new Date()) {
  let date = new Date(time);
  let nYear = date.getFullYear();
  let nMonth = date.getMonth() + 1;
  nMonth = nMonth < 10 ? '0' + nMonth : nMonth;
  let nDay = date.getDate();
  nDay = nDay < 10 ? '0' + nDay : nDay;
  let nHour = date.getHours();
  nHour = nHour < 10 ? '0' + nHour : nHour;
  let nMinutes = date.getMinutes();
  nMinutes = nMinutes < 10 ? '0' + nMinutes : nMinutes;
  let nSeconds = date.getSeconds();
  nSeconds = nSeconds < 10 ? '0' + nSeconds : nSeconds;
  return `${nYear}-${nMonth}-${nDay} ${nHour}:${nMinutes}:${nSeconds}`;
}
